/*
 * Image.cpp
 *
 *  Created on: 2011-02-20
 *      Author: sfournier
 */

#include "Image.h"

Image::Image(const char* path)
{
	this->path = path;

	image = 0;
	loaded = 0;
}

Image::~Image() {
	delete image;
}

void Image::load() {
	//Temporary storage for the image that's loaded
    SDL_Surface* loadedImage = NULL;

	//Load the image
    loadedImage = SDL_LoadBMP( path );

	//If nothing went wrong in loading the image
    if( loadedImage != NULL )
    {
        //Create an optimized image
        image = SDL_DisplayFormat( loadedImage );
        
        //Free the old image
        SDL_FreeSurface( loadedImage );
		
		if(image != NULL)
		{
		//Color Key
		Uint32 colorkey = SDL_MapRGB(image->format,242,196,252);
		//Ajout de la transparence
		SDL_SetColorKey(image,SDL_SRCCOLORKEY, colorkey);
		loaded = 1;
		}
	}

	
   
		
}
